﻿//////////////////////////////////////////
/// 提供界面, 方便对客户端发送一些内容
//////////////////////////////////////////
#ifndef _SHOW_WIDGET_
#define _SHOW_WIDGET_
#pragma execution_character_set("utf-8")
#include <QPushButton>
#include <QTextEdit>
#include <QWidget>

enum LOG_LEVEL {
    INFO,
    WARNING,
    FATAL
};

class ShowWidget : public QWidget
{
    /* 使用宏来自动添加文件和行号信息 */
#define ADD_LOG_MESSAGE(msg)            add_log_message(msg, __FILE__, __LINE__)
#define ADD_LOG_MESSAGE_LEVEL(msg, lvl) add_log_message_level(msg, lvl, __FILE__, __LINE__)
    Q_OBJECT
public:
    /* 获取单例实例的静态方法 */
    static ShowWidget* get_instance();
    /* 添加日志消息 */
    void add_log_message(const QString& message, const char* file = nullptr, int line = 0);
    void add_log_message_level(const QString& message, LOG_LEVEL level, const char* file = nullptr, int line = 0);
    /* 删除拷贝构造函数和赋值操作符 */
    ShowWidget(const ShowWidget&)            = delete;
    ShowWidget& operator=(const ShowWidget&) = delete;
private:
    explicit ShowWidget(QWidget* parent = nullptr);
    void init_ui();
    void connect_slots();
public slots:
    void send_btn_clicked();
private:
    QPushButton* send_btn;
    QPushButton* clear_btn;
    QPushButton* del_btn;
    QPushButton* friend_apply_btn;
    QPushButton* ac_friend_apply_btn;
    QPushButton* rej_friend_apply_btn;
    QPushButton* create_group_btn;
    QPushButton* send_image_btn;
    QPushButton* send_file_btn;
    QPushButton* send_speech_btn;
    QTextEdit*   log_output;
    // 单例实例指针
    static ShowWidget* instance;
};
#endif
